<?php
/**
 * Zend  Paginator from builder using adapter to doctrine
 *
 * @author Lukas Normantas
 */
class Areal_Paginator
{
    /**
     * Passes and sets up Doctrine Pager to Paginator Adapter
     *
     * @param Doctrine_Pager $pager
     * @param array $params
     * @param integer $hydrationMode
     * @return Zend_Paginator $paginator
     */
    static public function build($pager,  
                                 $params = array(),
                                 $hydrationMode = Doctrine::HYDRATE_ARRAY )
    {
        $adapter = new Areal_Paginator_Adapter_Doctrine($pager,
                                                        $params,
                                                        $hydrationMode);
        $paginator = new Zend_Paginator($adapter);
        $paginator->setCurrentPageNumber($pager->getPage());
        $paginator->setItemCountPerPage($pager->getMaxPerPage());
        return $paginator;
    }
}

